/* Define default values for variables */
body
{
    --line-width: 40em;
    --line-width-adaptive: 40em;
    --file-line-width: 40em;
    --sidebar-width: min(20em, 80vw);
    --collapse-arrow-size: 11px;
    --tree-vertical-spacing: 1.3em;
    --sidebar-margin: 12px;
}

:root
{
    background-color: #202124;
}

/*#region Sidebars */

.sidebar {
    height: 100%;
    font-size: 14px;
    z-index: 10;
    min-width: calc(var(--sidebar-width) + var(--divider-width-hover));
    max-width: calc(var(--sidebar-width) + var(--divider-width-hover));
    position: relative;
    overflow: hidden;
    overflow: clip;

    transition: min-width ease-in-out, max-width ease-in-out;
    transition-duration: .2s;
    contain: size;
}

#left-sidebar {
    left: 0;
}

#right-sidebar {
    right: 0;
}

.sidebar.is-collapsed {
    min-width: 0;
    max-width: 0;
}

.sidebar.floating {
    position: absolute;
}

.sidebar .leaf-content {
    height: 100%;
    min-width: calc(var(--sidebar-width) - var(--divider-width-hover));
    top: 0;
    padding: var(--sidebar-margin);
    padding-top: 4em;
    line-height: var(--line-height-tight);
    background-color: var(--background-secondary);
    transition: background-color,border-right,border-left,box-shadow;
    transition-duration: var(--color-fade-speed);
    transition-timing-function: ease-in-out;
    position: absolute;
    display: flex;
    flex-direction: column;
}

/* If the sidebar isn't collapsed the content should have the same width as it */
.sidebar:not(.is-collapsed) .leaf-content {
    min-width: calc(max(100%,var(--sidebar-width)) - 3px);
    max-width: calc(max(100%,var(--sidebar-width)) - 3px);
}

#left-sidebar-content
{
    left: 0;
    border-top-right-radius: var(--radius-l);
    border-bottom-right-radius: var(--radius-l);
}

#right-sidebar-content
{
    right: 0;
    border-top-left-radius: var(--radius-l);
    border-bottom-left-radius: var(--radius-l);
}

.sidebar #right-sidebar-content, .sidebar #left-sidebar-content
{
    contain: none !important;
    container-type: normal !important;
    animation: none !important;
}

/* Hide empty sidebars */
.sidebar:has(.leaf-content:empty):has(.topbar-content:empty)
{
    display: none;
}

.sidebar-topbar {
    height: calc(2.3em + 2 * var(--sidebar-margin));
    width: var(--sidebar-width);
    padding: var(--sidebar-margin);
    z-index: 1;

    position: fixed;
    display: flex;
    align-items: center;

    transition: width ease-in-out;
    transition-duration: inherit;
}

.sidebar.is-collapsed .sidebar-topbar {
    width: calc(2.3em + var(--sidebar-margin) * 2);
}

.sidebar .sidebar-topbar.is-collapsed
{
    width: 0;
}

#left-sidebar .sidebar-topbar {
    left: 0;
    flex-direction: row;
	border-top-right-radius: var(--radius-l);
}

#right-sidebar .sidebar-topbar {
    right: 0;
    flex-direction: row-reverse;
	border-top-left-radius: var(--radius-l);
}

#left-sidebar .topbar-content {
    margin-right: calc(2.3em + var(--sidebar-margin));
    flex-direction: row;
}

#right-sidebar .topbar-content {
    margin-left: calc(2.3em + var(--sidebar-margin));
    flex-direction: row-reverse;
}

.topbar-content {
    overflow: hidden visible;
    overflow: clip visible;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    transition: inherit;
}

.sidebar.is-collapsed .topbar-content {
    width: 0;
    transition: inherit;
}

.clickable-icon.sidebar-collapse-icon {
    background-color: transparent;
    color: var(--icon-color-focused);
    padding: 2px!important;
    margin: 0!important;
    height: 100%!important;
    width: 2.3em !important;
    margin-inline: 0.14em!important;
    position: absolute;
}

#left-sidebar .clickable-icon.sidebar-collapse-icon {
    transform: rotateY(180deg);
    right: var(--sidebar-margin);
}

#right-sidebar .clickable-icon.sidebar-collapse-icon {
    transform: rotateY(180deg);
    left: var(--sidebar-margin);
}

.clickable-icon.sidebar-collapse-icon svg.svg-icon {
    width: 100%;
    height: 100%;
}

.feature-title {
    margin-left: 1px;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-top: 0.75em;
    margin-bottom: 0.75em;
}

.feature-header
{
    display: flex;
    align-items: center;
    padding-top: 0;
    font-size: 1em;
    padding-left: 0;
}

body.floating-sidebars .sidebar
{
    position: absolute;
}

/*#endregion */

/*#region Content / Markdown Preview View */

body
{
    transition: background-color var(--color-fade-speed) ease-in-out;
}

#navbar:not(:empty)
{
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.5em 1em;
	width: 100%;
}

#main {
	display: flex;
	flex-direction: column;
	height: 100%;
	width: 100%;
	align-items: stretch;
	justify-content: center;
}

#main-horizontal {
    display: flex;
    flex-direction: row;
	flex-grow: 1;
    width: 100%;
    align-items: stretch;
    justify-content: center;
}

#center-content 
{
    flex-basis: 100%;
    max-width: 100%;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: opacity 0.2s ease-in-out;
    contain: inline-size;
}

.hide
{
    opacity: 0 !important;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

#center-content>.obsidian-document 
{
    padding-left: 2em;
    padding-right: 1em;
    margin-bottom: 0;
    width: 100%;
    width: -webkit-fill-available;
    width: -moz-available;
    width: fill-available;
    transition: background-color var(--color-fade-speed) ease-in-out;
    border-top-right-radius: var(--window-radius, var(--radius-m));
    border-top-left-radius: var(--window-radius, var(--radius-m));
    overflow-x: hidden !important;
    overflow-y: auto !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    contain: inline-size;
}

body #center-content>.obsidian-document>.markdown-preview-sizer 
{
    padding-bottom: 80vh;
    width: 100%;
    max-width: var(--line-width);
    flex-basis: var(--line-width);
    transition: background-color var(--color-fade-speed) ease-in-out;
    contain: inline-size;
}

#center-content>.obsidian-document>div
{
    width: 100% !important;
    transition: background-color var(--color-fade-speed) ease-in-out;
    contain: inline-size;
}

/* If the markdown view is displaying a raw file or embed then increase it's size to make everything as large as possible */
#center-content > .obsidian-document:not([data-type='markdown']).embed {
    display: flex;
    padding: 1em;
    height: 100%;
    width: 100%;
    align-items: center;
    justify-content: center;
}

#center-content > .obsidian-document:not([data-type='markdown']).embed > *
{
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

:not(h1,h2,h3,h4,h5,h6,li):has(> :is(.math, table)) 
{
    overflow-x: auto !important;
}

/* For custom view exports */
#center-content > .obsidian-document:not([data-type='markdown'])
{
    overflow-x: auto;
    contain: content;
    padding: 0;
    margin: 0;
    height: 100%;
}

.obsidian-document[data-type="attachment"]
{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

.obsidian-document[data-type="attachment"] > *
{
    outline: none;
    border: none;
    box-shadow: none;
}

.obsidian-document[data-type="attachment"] :is(img)
{
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.obsidian-document[data-type="attachment"] > :is(audio)
{
    width: 100%;
    max-width: min(90%, var(--line-width));
}

.obsidian-document[data-type="attachment"] > :is(embed, iframe, video)
{
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.canvas-wrapper > :is(.header, .footer)
{
    z-index: 100;
    position: absolute;
    display: flex;
    justify-content: center;
    flex-direction: column;
    width: 100%;
    align-items: center;
}

/*#endregion */

/*#region Loading */

.scroll-highlight 
{
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background-color: hsla(var(--color-accent-hsl),.25);
    opacity: 0;
    padding: 1em;
    inset: 50%;
    translate: -50% -50%;
    border-radius: var(--radius-s);
}

/*#endregion */
